<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8" />
    <!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
    <meta http-equiv="X-Content-Security-Policy" content="default-src 'self'; script-src 'self'" />
    <meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';" />
    <title>Hello from Electron renderer!</title>
</head>

<body>
    <h1>Hello from Electron renderer!</h1>
    <p>👋</p>
    <input id="content" type="text" value="Hello from Electron renderer!"/>
    <button onclick="save()">点击保存</button>
</body>

</html>
<script>
    function save() {
        const content = document.querySelector("#content").value;
        if (typeof myAPI !== 'undefined' && myAPI.saveFile) {
            myAPI.saveFile(content);
            alert('文件已保存！');
        } else {
            alert('当前不在 Electron 环境中');
        }
    }
</script>